package com.jia.leetCode;

/**
 * @program: Leetcode
 * @description: https://leetcode-cn.com/contest/biweekly-contest-33/problems/thousand-separator/
 * @author: STU756
 * @create: 2020-08-24 12:11
 */
public class Pro1556 {
    public String thousandSeparator(int n) {
        if(n < 0) return "";
        if(n == 0) return "0";
        StringBuilder sb = new StringBuilder();
        int count = 0;
        while(n > 0) {
            count++;
            sb.append(n % 10);
            if(count == 3) {

                sb.append(".");
                count = 0;
            }
            n /= 10;
        }
        if(sb.charAt(sb.length() - 1) == '.') sb.deleteCharAt(sb.length() - 1);
        return sb.reverse().toString();
    }
}
